package com.fieldchain.ex.fa100.ui.personal.activity;

import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.fieldchain.ex.fa100.R;
import com.fieldchain.ex.fa100.base.MyBaseActivity;
import com.fieldchain.ex.fa100.bean.User;
import com.fieldchain.ex.fa100.utils.common.MoneyAnimation;
import com.fieldchain.ex.fa100.utils.share.ShareManager;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/9/15
 */
public class AuxiliaryMoneyActivity extends MyBaseActivity implements View.OnClickListener {
    private RelativeLayout reaBack;
    private TextView tvCenter;
    private ImageView ivCny;
    private TextView tvCny;
    private ImageView ivUsd;
    private TextView tvUsd;


    private MoneyAnimation animation;
    private User user;
    private Handler mHadnler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case 0:
                    animation.attachView((Activity) mContext, ivCny, ivUsd, tvCny, tvUsd);
                    break;
            }
        }
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        animation.detachView();
    }

    @Override
    public void findView() {
        reaBack = findViewById(R.id.rea_back);
        tvCenter = findViewById(R.id.tv_center);
        ivCny = findViewById(R.id.iv_cny);
        tvCny = findViewById(R.id.tv_cny);
        ivUsd = findViewById(R.id.iv_usd);
        tvUsd = findViewById(R.id.tv_usd);
    }

    @Override
    public void setValue() {
        reaBack.setOnClickListener(this);
        ivCny.setOnClickListener(this);
        ivUsd.setOnClickListener(this);

        animation = new MoneyAnimation();
        mHadnler.sendEmptyMessageDelayed(0, 50);
        user = ShareManager.getInstance().getUser();
    }

    @Override
    public int getLayout() {
        return R.layout.activity_auxi;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.rea_back:
                finish();
                break;
            case R.id.iv_cny:
               animation.showCny();
                break;
            case R.id.iv_usd:
                animation.showUsd();
                break;
        }
    }
}
